import Taro from '@tarojs/taro'
const getUrl = async () => {
    const appid = 'wx590c68263ebc1cd4';
    const secret = '214d1ebb6077cdccbfe234a422d9ed72';
    const http = `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appid}&secret=${secret}`
    const data = await getHttps(http, 'GET')
    // console.log(data)
    if(data.data.access_token){
        const https = `https://api.weixin.qq.com/wxa/generate_urllink?access_token=${data.data.access_token}`;
        const  datas={
            path:'pages/home/index',
            env_version:'release'
        }
        const res = await getHttps(https, 'POST',datas)
        console.log(res)
    }

}
const getHttps = (http: string, method: string | any, data?:object) => {
    return Taro.request({
        url: http,
        method: method,
        data
    })
}

export default getUrl